<template>
	<view class="nav-wrap" id='nav-wrap' :style="{height:headAllHeight}">
		<view id='head-wrap' class='head-wrap':style="{height:headAllHeight}">
			<view class="head-inner" :style='{background:background,backgroundSize:bgSize,paddingTop:statusBarHeight}'>
				<view class='head-con' v-if='headType==0'>
					<view class="back-icon" @tap='backEv' v-if='showBack'>
						<uni-icons type="left" size="20" :color="color"></uni-icons>
					</view>
					<view class="home" v-if='showHome' @tap='toHome'>
						<!-- <u-icon name='home' color='#fff' size="48" v-if='mode=="white"'></u-icon>
						<u-icon name='home' color='#333' size="48" v-if='mode=="black"'></u-icon> -->
					</view>
					<view class="title" :style="{color:color}">{{title}}</view>
					<view class="detail" v-if='rightTip' @tap='goEv'>{{rightTip}}</view>
				</view>
				<view class='head-search head-con' v-if='headType==1'>
					<slot></slot>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
	const app = getApp()
	export default {
		name: 'blind-navbar',
		data() {
			return {
				statusBarHeight: app.globalData.statusBarHeight + 'px',
				headAllHeight: app.globalData.headAllHeight + 'px'
			}
		},
		props: {
			headType: {
				type: Number,
				default: 0,
			}, //0 --- 普通类型  1 --- 搜索类型 
			title: String, //标题
			background: {
				type:String,
				default:'#fff'
			},
			bgSize: String,
			color: {
				type:String,
				default:'#333'
			},
			showBack: {
				type: Boolean,
				default: true
			},
			showHome:{
				type:Boolean,
				default:false
			},
			rightTip: {
				type: String,
				default: ''
			},
			pageType:{
				type:String,
				default:'1'
			}
		},
		mounted() {
		},
		methods: {
			backEv() {
				if(this.pageType == 1){
					uni.navigateBack({
						delta: 1
					})
				}else{
					uni.switchTab({
						url:'/pages/tabPage/blind-page/blind-page'
					})
				}
			},
			toHome(){
				uni.switchTab({
					url:'/pages/tabPage/blind-page/blind-page'
				})
			},
			goEv(){
				this.$emit('goEv')
			}
		}
	}
</script>

<style lang="scss" scoped>
	.head-wrap {
		width: 100%;
		position: fixed;
		left: 0;
		top: 0;
		z-index: 999;
	}
	.head-inner{
		width:100%;
		height: 44px;
	}
	.head-con {
		width: 100%;
		height: 44px;
		position: relative;
	}

	.back-icon {
		width: 60rpx;
		height: 60rpx;
		position: absolute;
		left: 0rpx;
		top: 50%;
		margin-top: -30rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		image {
			width: 16rpx;
			height: 28rpx;
		}
	}
	.home{
		width: 44px;
		height: 44px;
		position: absolute;
		left:0;
		top:0;
		display: flex;
		align-items: center;
		justify-content: center;
	}
	.detail {
		font-size: 28rpx;
		font-weight: bold;
		color: #707070;
		position: absolute;
		right: 30rpx;
		top: 50%;
		margin-top: -18rpx;
	}

	.title {
		width:300rpx;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
		text-align: center;
		font-size: 30rpx;
		font-weight: bold;
		position: absolute;
		left: 50%;
		top: 50%;
		transform: translate(-50%, -50%);
		font-family: PingFangSC-Regular;
	}

	.title2 {
		color: #fff;
	}
</style>
